package store.entry;

import java.util.Objects;

//用户类
public class User {
    //要求用户名不能重复，密码长度不能少于6位
    private String username;//用户名
    private String password;//用户密码
    private String otherName;//用户别名
    private int age;//用户年龄

    public User() {
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
    public User(String username, String password, String otherName, int age) {
        this.username = username;
        this.password = password;
        this.otherName = otherName;
        this.age = age;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getOtherName() {
        return otherName;
    }

    public void setOtherName(String otherName) {
        this.otherName = otherName;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return age == user.age && Objects.equals(username, user.username) && Objects.equals(password, user.password) && Objects.equals(otherName, user.otherName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, password, otherName, age);
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", otherName='" + otherName + '\'' +
                ", age=" + age +
                '}';
    }
}
